package com.t174.car.controller;



import com.t174.car.dao.CarComponentsDao;
import com.t174.car.dao.CarConfigDao;
import com.t174.car.dao.CarPurchaseDao;
import com.t174.car.entity.CarComponents;
import com.t174.car.entity.CarConfig;
import com.t174.car.entity.CarPurchase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/carsss")
@Scope("prototype")
public class CarComponentsController {
    @Autowired
    CarComponentsDao carComponentsDao;
    @Autowired
    CarPurchaseDao carPurchaseDao;
    @Autowired
    CarConfigDao carConfigDao;
    @RequestMapping("showcoms")
    @ResponseBody
    public List<CarComponents> query(){
        return  carComponentsDao.showqer();
    }
    @RequestMapping("/addCarCount")
    @ResponseBody
    public int upCarCount(int cid, CarPurchase carPurchase){
        //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        System.out.println();// new Date()为获取当前系统时间
        System.out.println(carPurchase.getBrand()+"-"+carPurchase.getLevel()+"-"+cid);
        int count = carConfigDao.addCarCount(carPurchase.getCount(),cid);
        count = carPurchaseDao.addCar(carPurchase);
        return count;//;
    }
}
